<template>
	<div class="inProcessing2">

		<div>
			<orderStatistics :myInfo ='myInfo' :roleID='roleID'  @getData='getData'/>
			<el-popover placement="left" trigger="click">
				<template>
					<el-checkbox v-model="tableHeader.checked" @change="selectAll">全选</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked0">等待提交时长</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked1">订单编号</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked4">流程状态</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked14">申报名称</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked16">专利类型</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked5">专利权人</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked6">发明人</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked28">发明人推荐码</el-checkbox>
					<br />
					<el-checkbox v-if="roleID!=2" v-model="tableHeader.checked8">联络人</el-checkbox>
					<br v-if="roleID!=2" />
					<el-checkbox v-model="tableHeader.checked7">身份证号</el-checkbox>
					<br />
					<el-checkbox v-if="roleID!=2" v-model="tableHeader.checked9">电话</el-checkbox>
					<br v-if="roleID!=2" />
					<el-checkbox v-model="tableHeader.checked10">邮箱</el-checkbox>
					<br />
					<!-- <el-checkbox v-model="tableHeader.checked12">内容审核文件</el-checkbox>
					<br /> -->
					<!-- <el-checkbox v-model="tableHeader.checked15">状态</el-checkbox>
					<br /> -->
					<el-checkbox v-model="tableHeader.checked17">提交机构</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked18">申请号</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked23">缴费状态</el-checkbox>
					<br />
					<el-checkbox v-if="roleID!=2" v-model="tableHeader.checked2">代理人</el-checkbox>
					<br v-if="roleID!=2" />
					<el-checkbox v-model="tableHeader.checked3">流程人员</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked11">审核次数</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked24">备注</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked26">同日提交案件</el-checkbox>
					<br />
					<el-checkbox v-model="tableHeader.checked13">完成文件上传</el-checkbox>
					<br />
					<el-checkbox v-if="roleID!=2" v-model="tableHeader.checked19">申报时间</el-checkbox>
					<br v-if="roleID!=2" />
					<el-checkbox v-if="roleID!=2" v-model="tableHeader.checked20">更新时间</el-checkbox>
					<br v-if="roleID!=2" />
					<el-checkbox v-if="roleID ==2" v-model="tableHeader.checked21">接单时间</el-checkbox>
					<br v-if="roleID==2" />
					<el-checkbox  v-model="tableHeader.checked22">定稿时间</el-checkbox>
					<br/>
					<el-checkbox  v-model="tableHeader.checked25">发明人提交时间</el-checkbox>
					<br/>
					<el-checkbox  v-model="tableHeader.checked27">缴纳年费日期</el-checkbox>
					<br/>
				</template>
				<el-button style="float: right;margin-bottom: 5px;margin-top: 0;" slot="reference" icon="el-icon-arrow-down">显示字段</el-button>
			</el-popover>
			<!-- <span v-if="roleID!=2"  >
				<i class="el-icon-download"></i> <a href="javascript:;">导出列表</a>
			</span> -->
			<el-button type="text"
				class="fr mr10 exportExcel"
				v-if="roleID!=2"
				icon='el-icon-download'
				@click="exportExcel('国知局后订单')"
				v-no-more-click:3000>
				导出列表
			</el-button>
			<a id='exportZIPDOM' :href="exportCpcURL"></a>
			<!-- 列表查找 -->
			<span class="down-execel">
				<!-- <Icon type="ios-funnel-outline" /><a href="javascript:;">筛选条件</a> -->
				<Poptip v-model="showFilter" placement="bottom-end" @on-popper-show ='getAllAgent'>
					<!-- <Icon type="ios-funnel-outline" /> -->
					<i class="el-icon-search poptip-condition-add"></i>
					<a href="javascript:;">列表查找</a>
					<!-- <div slot="title"><i></i></div> -->
					<div slot="content">
						<Poptip v-model="showFilterCondition" placement="bottom-start" class='poptip-condition'>
							<i class="el-icon-plus poptip-condition-add"></i>
							<a href="javascript:;" class='poptip-condition-add'>添加过滤条件</a>


							<div slot="content" class="condition-list">
								<ul>
									<template v-if='roleID === 4' >
										<li v-for="(item, index) in columns2" :key="index" class='poptip-condition-item' @click="addFilterCondition(item)">{{item.label}}</li>
									</template>
									<li v-else v-for="(item, index) in columns" :key="index" class='poptip-condition-item' @click="addFilterCondition(item)">{{item.label}}</li>
								</ul>
							</div>
						</Poptip>

						<el-form :model="conditionForm" ref="conditionForm" label-min-width="120px" class="demo-dynamic" @submit.native.prevent>
							<el-form-item v-for="(condition, index) in conditionForm.condition" :label="condition.label" :key="condition.key"
								:prop="'condition.' + index + '.value'" :rules="{
										required: true, message: condition.label +'不能为空', trigger: 'blur'
									}">
								<el-select
									size="small"
									filterable
									v-model="condition.value"
									v-if='condition.label === "代理人"'>
									<el-option
										v-for="item in agentOptions"
										:key="item.id"
										:label="item | agentNumAddName"
										:value="item.id">
									</el-option>
								</el-select>
								<el-select
									size="small"
									filterable
									v-model="condition.value"
									v-else-if='condition.label === "流程人员"'>
									<el-option
										v-for="item in processOptions"
										:key="item.id"
										:label="item.name"
										:value="item.id">
									</el-option>
								</el-select>

								<el-select v-else-if='condition.label === "流程状态"' v-model="condition.value" placeholder="请选择流程状态" size="small">
									<el-option label="等待提交国知局" value="等待提交国知局"></el-option>
									<el-option label="已提交国知局" value="已提交国知局"></el-option>
									<el-option label="等待补正" value="等待补正"></el-option>
									<el-option label="已补正" value="已补正"></el-option>
									<el-option label="等待答复" value="等待答复"></el-option>
									<el-option label="已答复" value="已答复"></el-option>
									<el-option label="初步审查合格" value="初步审查合格"></el-option>
									<el-option label="实质审查中" value="实质审查中"></el-option>
									<el-option label="驳回" value="驳回"></el-option>
									<el-option label="授权" value="授权"></el-option>
									<el-option label="下证" value="下证"></el-option>
									<el-option label="撤案" value="撤案"></el-option>
								</el-select>
								<el-select v-else-if='condition.label === "缴费状态"' v-model="condition.value" placeholder="请选择缴费状态" size="small">
									<el-option label="已缴费" value="1"></el-option>
									<el-option label="未缴费" value="2"></el-option>
									<!-- <el-option label="已退款" value="3"></el-option> -->
								</el-select>

								<el-date-picker
									v-model="submitTime"
									type="daterange"
									placeholder="选择日期"
									value-format="yyyy-MM-dd"
									size="small"
									:validate-event='false'
									@input = 'changInput'
									v-else-if='condition.label === "申报时间"'>
								</el-date-picker>
								<el-date-picker
									v-model="updatedTime"
									type="daterange"
									placeholder="选择日期"
									value-format="yyyy-MM-dd"
									size="small"
									:validate-event='false'
									@input = 'changInput'
									v-else-if='condition.label === "更新时间"'>
								</el-date-picker>

								<el-date-picker
									v-model="createdTime"
									type="daterange"
									placeholder="选择日期"
									value-format="yyyy-MM-dd"
									size="small"
									:validate-event='false'
									@input = 'changInput'
									v-else-if='condition.label === "定稿时间"'>
								</el-date-picker>
								<el-date-picker
									v-model="userSubmitTime"
									type="daterange"
									placeholder="选择日期"
									value-format="yyyy-MM-dd"
									size="small"
									:validate-event='false'
									@input = 'changInput'
									v-else-if='condition.label === "发明人提交时间"'>
								</el-date-picker>
								<el-date-picker
									v-model="condition.value"
									type="daterange"
									placeholder="选择日期"
									value-format="yyyy-MM-dd"
									size="small"
									:validate-event='false'
									@input = 'changInput'
									v-else-if='condition.label === "缴纳年费日期"'>
								</el-date-picker>

								<el-select v-else-if='condition.label === "专利类型"' v-model="condition.value" placeholder="请选择专利类型" size="small">
									<el-option label="发明专利" value="F"></el-option>
									<el-option label="实用新型" value="S"></el-option>
									<el-option label="外观设计" value="W"></el-option>
									<!-- <el-option label="不确定" value="不确定"></el-option> -->
								</el-select>

								<el-input v-else size="small" v-model="condition.value" @keyup.enter.native="submitsearch('conditionForm')"></el-input>
								<el-button @click.stop="removeDomain(condition)" size="mini">删除</el-button>
							</el-form-item>
							<div class='btns'>
								<el-button @click="submitsearch('conditionForm')" size="mini">查询</el-button>
								<el-button @click.stop="resetForm('conditionForm')" size="mini">重置</el-button>
							</div>

						</el-form>
					</div>
				</Poptip>
			</span>
		</div>

		<el-table
      :data="tableData.slice(tableStart,tableEnd)"
      border
      style="width: 100% "
      v-loading="loading"
      ref="orderTb"
			height="88%"
			@row-click="lookOrder"
			@sort-change='tableSortChange'>
      <!-- :span-method="spanMethod" -->
			<!-- :row-class-name="tableRowClassName" -->
			<el-table-column prop="id" label="ID" min-width="60" align="left" v-if='checked99'>
				<template slot-scope="scope">{{(scope.$index+1)+(currentPage-1)*tableSize}}</template>
			</el-table-column>
			<!-- <el-table-column type="index" index="0" label="ID" min-width="80" align="left"></el-table-column> -->

			<el-table-column v-if="tableHeader.checked0" label="等待提交时长(天)" min-width="160" align="left" prop="wait_submit" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						<!-- 等待提交国知局超过10天标红 -->
						<template v-if='scope.row.status=="等待提交国知局"'>
							<span  :class=" getProcessingTime(scope.row) > 10 ? 'font_danger' : ''">
								{{ getProcessingTime(scope.row) }}
							</span>
						</template>
						<!-- 等待答复超过30天标红 -->
						<template v-else-if='scope.row.status=="等待答复"'>
							<span  :class=" getProcessingTime(scope.row) > 30 ? 'font_danger' : ''">
								{{ getProcessingTime(scope.row) }}
							</span>
						</template>
						<span v-else>
							{{ getProcessingTime(scope.row) }}
						</span>
					</span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked1" show-overflow-tooltip prop="order_number" label="订单编号" min-width="180" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked4" show-overflow-tooltip prop="status" label="流程状态" min-width="120" align="left" sortable='custom'>
				<template slot-scope="scope">
					{{ scope.row.status }}
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked14" show-overflow-tooltip prop="name" label="申报名称" min-width="200" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked16" show-overflow-tooltip prop="type" label="专利类型" min-width="120" align="left" sortable='custom'>
				<template slot-scope="scope">{{scope.row.type == 'F' ? '发明专利' : (scope.row.type == 'S' ? '实用新型' : '外观设计')}}</template>
			</el-table-column>
			<el-table-column show-overflow-tooltip v-if="tableHeader.checked5" prop="patent_user" sortable='custom' label="专利权人" min-width="120" align="left">
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.patent_user}}
					</span>
				</template>
			</el-table-column>
			<el-table-column show-overflow-tooltip v-if="tableHeader.checked6" prop="user_name" sortable='custom' label="发明人" min-width="120" align="left">
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.user_name}}
					</span>
				</template>
			</el-table-column>
			<el-table-column show-overflow-tooltip v-if="tableHeader.checked28" prop="referral_code" sortable='custom' label="发明人推荐码" min-width="160" align="left">
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.consumer | channelPid}}
					</span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked8" show-overflow-tooltip prop="liaisons" label="联络人" min-width="100" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.liaisons}}
					</span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked7" show-overflow-tooltip prop="id_card" label="身份证号" min-width="180" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.id_card}}
					</span>
				</template>
			</el-table-column>

			<el-table-column v-if="tableHeader.checked9" show-overflow-tooltip prop="liaisons_tel" label="电话" min-width="150" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.liaisons_tel}}
					</span>
				</template>
			</el-table-column>
			<el-table-column show-overflow-tooltip v-if="tableHeader.checked10" prop="liaisons_email" label="邮箱" min-width="200" sortable='custom' align="left">
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						{{ scope.row.order.liaisons_email}}
					</span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked17" show-overflow-tooltip prop="organization" label="提交机构" min-width="120" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked18" show-overflow-tooltip prop="application_number" label="申请号" min-width="120" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked23" show-overflow-tooltip prop="consumer_pay_status" label="缴费状态" min-width="120" align="left" sortable='custom'>
				<template slot-scope="scope">
						<!-- {{ scope.row.order.consumer_pay_status == 1 ? '已缴费' : '未缴费'}} -->
						<template v-if="scope.row.status != '撤案'">
							<!-- <span v-if='scope.row.consumer_pay_status == 1' class="font_success">已缴费</span>
							<span v-else class="font_danger">未缴费</span> -->
							<span :class='scope.row.consumer_pay_status == 1 || scope.row.consumer_pay_status == 0 ? "font_success" : "font_danger"'>
								{{ scope.row.consumer_pay_status| payStatus }}
							</span>
						</template>

				</template>
			</el-table-column>

			<el-table-column v-if="tableHeader.checked2 && roleID !=2" show-overflow-tooltip prop="agent" label="代理人" min-width="140" align="left" sortable='custom'>
				<template slot-scope="scope">

					<!-- <span v-if="scope.row.order"> -->
						<template v-if="scope.row.agent">
							{{ scope.row.agent | agentNumAddName}}
						</template>
					<!-- </span> -->
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked3 " show-overflow-tooltip prop="process" label="流程人员" min-width="120" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">
						<template v-if="scope.row.order.process">
							{{ scope.row.order.process.name}}
						</template>
					</span>
					<!-- {{ scope.row.order.process | processNumber}} -->
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked11" prop="opinions_count" label="审核次数" min-width="120" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">{{ scope.row.order.opinions_count }}</span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked24" show-overflow-tooltip prop="remarks" label="备注" min-width="120" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">{{ scope.row.order.remarks }}</span>
					<span v-else></span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked26" show-overflow-tooltip prop="same_day_number" label="同日提交案件" min-width="200" align="left" sortable='custom'>
				<template slot-scope="scope">
					<span v-if="scope.row.order">{{ scope.row.order.same_day_number ? scope.row.order.same_day_number : '无同日提交案件' }}</span>
					<span v-else></span>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked13" prop="fish_file" label="完成文件上传" min-width="200" align="left">
				<template slot-scope="scope">
					<template v-if="scope.row.order">
						<div class="flie-hid">
							<a v-for="item in scope.row.order.fishfileArr" :key="item.id" :href="baseUrl +'/api/download?path=' + item.file +'/'+ item.path"
							:download="item.path" :title="item.path" class="el-icon-tickets file_sh" @click.stop="stopLook"></a>
						</div>
					</template>
				</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked19 && roleID !=2" show-overflow-tooltip label="申报时间" min-width="150" prop="submit_at" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked20 && roleID !=2" show-overflow-tooltip label="更新时间" min-width="180" prop="updated_at" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked22 && roleID !=2" show-overflow-tooltip label="定稿时间" min-width="180" prop="created_at" align="left" sortable='custom'></el-table-column>
			<el-table-column v-if="tableHeader.checked21 && roleID == 2" show-overflow-tooltip label="接单时间" min-width="180" align="left">
				<template slot-scope="scope">{{ getOrderTakingTime(scope.row) }}</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked25" show-overflow-tooltip prop='order_created_at' sortable='custom' label="发明人提交时间" min-width="180" align="left">
				<template slot-scope="scope">{{ scope.row | usetSubmitTime }}</template>
			</el-table-column>
			<el-table-column v-if="tableHeader.checked27" show-overflow-tooltip prop='pay_annual_fee_date' sortable='custom' label="缴纳年费日期" min-width="180" align="left">
				<template slot-scope="scope">{{ scope.row.pay_annual_fee_date }}</template>
			</el-table-column>

			<!-- 代理人 -->
			<el-table-column :fixed="isFixed" min-width="100" v-if="roleID == 2" align="right">
				<template slot="header">
					<span class="tableLastCol">操作</span>
				</template>
				<template slot-scope="scope">
					<el-button v-no-more-click:3000 type="primary" size="small" @click.stop="lookOrder(scope.row)">处理订单</el-button>
					<!-- <div v-if="scope.row.status == '代理人撰写中'">
            <countDown :endTime="scope.row" :callback="callback" endText="已超出30天"></countDown>
          </div>-->
				</template>
			</el-table-column>

			<!-- 流程人员 -->
			<el-table-column :fixed="isFixed" min-width="100" v-else-if="roleID == 4 && checked99" align="right">
				<template slot="header">
					<span class="tableLastCol3">操作</span>
				</template>
				<template slot-scope="scope">
					<!-- <el-button v-no-more-click:3000 v-if="scope.row.consumer_pay_status == 1" type="primary" size="small" :disabled="(scope.row.consumer_pay_status == 1) || getSendPayNotice(scope.row.statuss) " @click.stop="sendPayNotice(scope.row)">已&nbsp;&nbsp;缴&nbsp;&nbsp;费</el-button> -->
					<el-button v-no-more-click:3000 type="primary" size="small" :disabled="disabledSendPayNotice(scope.row)" @click.stop="sendPayNotice(scope.row)">{{ (scope.row.consumer_pay_status == 1 || scope.row.consumer_pay_status == 0) ? '发送受理' : '发送缴费' }}</el-button>
					<!-- <el-button v-if="roleID == 4 || roleID == 7" type="success" size="small"  @click.stop="uploadCredential(scope.row)" v-no-more-click:3000>上传证书</el-button> -->
				</template>
			</el-table-column>

		</el-table>

		<el-pagination class="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
			:page-sizes="pageSizes" :page-size="Number(pageSize)" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>

		<!-- 查看 -->
		<lookDialog
			:stepsText="stepsText"
			:order_process="order_process"
			:order_agent="order_agent"
			:orderRow = 'orderRow'
			:formProcess='true'
			ref="orderDialog"
			@chageData="search"></lookDialog>

		<!-- 进度 -->
		<processScheduleDialog ref="scheduleDialog" :stepsText="stepsText" :isfalse='true'></processScheduleDialog>

		<!-- 定稿文件 -->
		<finalizationDialog ref="finalizationFile"></finalizationDialog>

		<xy-excel-export-template ref="TerminalExportExcel"></xy-excel-export-template>

		<!-- 发送缴费通知 -->
		<el-dialog
			title="发送缴费通知"
			@close = 'closeSendPayNotice'
			center
			min-width='40%'
			:visible.sync="showSendPayNotice"
			@open = 'openPayNotice'
			class="sendPayNoticeDialog">
			<div>
				<el-select v-model="sendType" size="small" placeholder="请选择发送文件类型">
					<el-option label="只发送缴费通知书" :disabled="disabledPay" value="1"></el-option>
					<el-option label="只发送受理通知书" value="2" :disabled="disabledAccept"></el-option>
					<el-option label="全部发送" value="3" :disabled="disabledAll"> </el-option>
				</el-select>

			<el-checkbox class="mb10" v-model="isSendEmail">是否发送邮件</el-checkbox>
			</div>
      <el-upload
				v-if='sendType != 1'
				class="upload"
				:action="iploadULR"
				:on-remove="handleRemove1"
				:on-change="handleChange1"
				:http-request="uploadSectionFile"
				multiple
				:auto-upload="true"
				:limit="1"
				:file-list="fileList2">
				<el-button v-no-more-click:3000 size="small" type="success">&emsp;选择通知书&emsp;</el-button>
				<div slot="tip" class="el-upload__tip">一个文件直接上传,如果有多个文件,请将文件夹压缩后上传</div>
				<div slot="tip" class="el-upload__tip">文件格式为：日期-订单编号-专利名称-通知书-申请号</div>
				<div slot="tip" class="el-upload__tip">例：yyyy-mm-dd_#############_###_专利申请受理通知书_#############</div>
			</el-upload>
			<el-button  v-no-more-click:3000 size="small" type="primary"  :loading="sendPayNoticeLoading" @click="submitPayNotice" class='btn-send'>&emsp;发送通知书&emsp;</el-button>
			<el-button v-if='showPayNotice' v-no-more-click:3000 size="small" type="success"  @click="viewNotice" class='btn-send'>预览缴费通知书</el-button>
			<el-button v-if='showPayNotice' v-no-more-click:3000  size="small" type="success" :disabled="disabledEditPayNotice"  @click="editNotice" class='btn-send'>修改缴费通知书</el-button>

    </el-dialog>

		<!-- 预览缴费通知书 -->
		<a id='viewNotice' :href="viewNoticeURL" target="_blank"></a>

		<!-- 修改缴费通知书 -->
		<editNoticeDialog ref='editNoticeDialog'></editNoticeDialog>
		<!-- 上传证书 -->
		<uploadCredentialDialog ref='uploadCredentialDialog' @refresh="search"/>
	</div>
</template>

<script>
	import lookDialog from "./dialogPage/dialogOrder"; //查看弹出层
	import processScheduleDialog from "./dialogPage/processSchedule"; //进度弹出层
	import finalizationDialog from "./dialogPage/uploadFile"; //定稿文件弹出层
	import countDown from "~/components/countDown";
	import editNoticeDialog from "./dialogPage/editNoticeDialog"
	// 方法的JS文件
	import {
		getOrderList,
		getFinalsList
	} from "~/api/order";
	import orderFn from "./getOrderList";
	import axios from "axios";
	import xyExcelExportTemplate from "~/components/ExcelExportTemplate";
	import orderStatistics from "~/components/orderStatistics"
	import uploadCredentialDialog from './dialogPage/upload-credential'

	import {apiAddress} from '~/util/config'
	export default {
		head: {
			title: "国知局后订单"
		},
		name: "inProcessing",
		components: {
			lookDialog, //查看弹出层
			processScheduleDialog, //进度弹出层
			finalizationDialog, //定稿文件上传弹出层
			countDown,
			xyExcelExportTemplate,
			orderStatistics,
			editNoticeDialog,
			uploadCredentialDialog
		},
		data() {
			return {
				exportCpcURL:'',
				loading: true,
				isFixed: "right",
				tableData: [],
				//默认域名
				baseUrl: global.baseurl,
				//角色
				roleID: 1,
				// 分页
				tableSize: 10, //一页几条
				tableStart: 0, //table数组过滤的第一条索引
				tableEnd: 10, //table数组过滤的最后一条索引
				currentPage: 1, //目前在第几页
				pageSizes: [25, 50], //一页可以几条
				pageSize: 25,
				strTime: "",
				myInfo: {
					annual_fee_count: 0
				},
				tableHeader: {
					checked: true,
					checked0: true,
					checked1: true,
					checked2: true,
					checked3: true,
					checked4: true,
					checked5: true,
					checked6: true,
					checked7: true,
					checked8: true,
					checked9: true,
					checked10: true,
					checked11: true,
					checked12: true,
					checked13: true,
					checked14: true,
					checked15: true,
					checked16: true,
					checked17: true,
					checked18: true,
					checked19: true,
					checked20: true,
					checked21: true,
					checked22: true,
					checked23: true,
					checked24: true,
					checked25: true,
					checked26: true,
					checked27: true,
					checked28: true,
				},
				total: 0,
				checked99: true,
				order_process: {},
				order_agent: null,
				showFilter: false, // 控制显示筛选条件
				showFilterCondition: false,
				conditionForm: {
					condition: []
				}, //筛选条件
				columns: [
					{
						label: '代理人',
						id: 1,
						parameter: 'agent_id'
					},
					{
						label: '订单编号',
						id: 2,
						parameter: 'order_number'
					},
					{
						label: '流程状态',
						id: 3,
						parameter: 'status'
					},
					{
						label: '专利类型',
						id: 4,
						parameter: 'type'
					},
					{
						label: '流程人员',
						id: 5,
						parameter: 'process_id'
					},
					{
						label: '拟申报专利名称',
						id: 6,
						parameter: 'patent_name'
					},
					{
						label: '申报名称',
						id: 7,
						parameter: 'name'
					},
					{
						label: '申请号',
						id: 8,
						parameter: 'application_number'
					},
					{
						label: '提交机构',
						id: 9,
						parameter: 'organization'
					},
					{
						label: '联络人',
						id: 10,
						parameter: 'liaisons'
					},
					{
						label: '电话',
						id: 11,
						parameter: 'liaisons_tel'
					},
					{
						label: '发明人',
						id: 12,
						parameter: 'user_name'
					},
					{
						label: '发明人推荐码',
						id: 21,
						parameter: 'referral_code'
					},
					{
						label: '专利权人',
						id: 13,
						parameter: 'patent_user'
					},
					{
						label: '缴费状态',
						id: 18,
						parameter: 'consumer_pay_status'
					},
					{
						label: '身份证号',
						id: 19,
						parameter: 'id_card'
					},
					{
						label: '邮箱',
						id: 14,
						parameter: 'liaisons_email'
					},
					{
						label: '申报时间',
						id: 15,
						parameter: 'subimt_time'
					},
					{
						label: '更新时间',
						id: 16,
						parameter: 'updated_time'
					},
					{
						label: '定稿时间',
						id: 17,
						parameter: 'created_time'
					},

					{
						label: '发明人提交时间',
						id: 20,
						parameter: 'order_created'
					},
					{
						label: '缴纳年费日期',
						id: 22,
						parameter: 'pay_annual_fee_date'
					},
				],
				columns2: [

					{
						label: '订单编号',
						id: 2,
						parameter: 'order_number'
					},
					{
						label: '流程状态',
						id: 3,
						parameter: 'status'
					},
					{
						label: '专利类型',
						id: 4,
						parameter: 'type'
					},

					{
						label: '拟申报专利名称',
						id: 6,
						parameter: 'patent_name'
					},
					{
						label: '申报名称',
						id: 7,
						parameter: 'name'
					},
					{
						label: '申请号',
						id: 8,
						parameter: 'application_number'
					},
					{
						label: '提交机构',
						id: 9,
						parameter: 'organization'
					},
					{
						label: '联络人',
						id: 10,
						parameter: 'liaisons'
					},
					{
						label: '电话',
						id: 11,
						parameter: 'liaisons_tel'
					},
					{
						label: '身份证号',
						id: 19,
						parameter: 'id_card'
					},
					{
						label: '邮箱',
						id: 14,
						parameter: 'liaisons_email'
					},
					{
						label: '发明人',
						id: 12,
						parameter: 'user_name'
					},
					{
						label: '发明人推荐码',
						id: 22,
						parameter: 'referral_code'
					},
					{
						label: '专利权人',
						id: 13,
						parameter: 'patent_user'
					},
					{
						label: '缴费状态',
						id: 18,
						parameter: 'consumer_pay_status'
					},
					{
						label: '代理人',
						id: 1,
						parameter: 'agent_id'
					},
					{
						label: '流程人员',
						id: 5,
						parameter: 'process_id'
					},
					{
						label: '申报时间',
						id: 15,
						parameter: 'subimt_time'
					},
					{
						label: '更新时间',
						id: 16,
						parameter: 'updated_time'
					},
					{
						label: '定稿时间',
						id: 17,
						parameter: 'created_time'
					},
					{
						label: '发明人提交时间',
						id: 20,
						parameter: 'order_created'
					},
					{
						label: '缴纳年费日期',
						id: 21,
						parameter: 'pay_annual_fee_date'
					},
				],
				lastTime: 0,
				searchValue: '',
				submitTime: [],
				updatedTime: [],
				userSubmitTime: [],
				agentOptions: [],
				processOptions: [],
				iploadULR: '',
				showSendPayNotice: false,
				fileList: [],
				orderID: 0,
				fileListV: [],
        fileList2: [],
				fileListV2: [],
				paramsByOrder: {
					status: "修改,等待提交国知局,已提交国知局,等待补正,已补正,等待答复,已答复,发明人确认答复中,发明人确认补正中,初步审查合格,实质审查中,驳回,授权,下证,撤案",
				},
				sendPayNoticeLoading: false,
				stepsText:[
					'等待提交国知局',
					'已提交国知局',
					'补正/答复',
					'国知局审查中',
					'授权'
				],
				orderRow: {},
				createdTime: [],
				viewNoticeURL: '',
				viewNoticeDOM: null,
				exportZIPDOM: null,
				sendType: "1",
				apiAddress: apiAddress,
				disabledEditPayNotice: false,
				isSendEmail: true

			};
		},
		async asyncData({
			$axios,
			store
			}) {
			let paramsByOrder = {
				status: "修改,等待提交国知局,已提交国知局,等待补正,已补正,等待答复,已答复,发明人确认答复中,发明人确认补正中,初步审查合格,实质审查中,驳回,授权,下证,撤案",
			};
			// if (store.state.user.role_id == 4) {
			// 	paramsByOrder.process_id = store.state.user.id;
			// }
			return orderFn.getFinalsOrder($axios, store, paramsByOrder);
		},
		computed: {
			showPayNotice () {
				if (this.sendType == '3' || this.sendType == '1') {
					return true
				} else {
					return false
				}
			},
			disabledPay () {
				if(this.orderRow.statuss) {
					let sta = this.orderRow.statuss
					let isPay = this.orderRow.consumer_pay_status == 1 || this.orderRow.consumer_pay_status == 0
					if(this.getSendPayNotice(sta) || isPay) {
						return true
					} else {
						return false
					}
				} else {
					return false
				}
			},
			disabledAccept () {
				if(this.orderRow.statuss) {
					let sta = this.orderRow.statuss
					let isSendAccept = sta.findIndex(v => v.id == 19)
					let isPay = this.orderRow.consumer_pay_status == 2
					if (isPay && isSendAccept == -1) {
						return false
					} else {
						return true
					}
				} else {
					return false
				}
			},
			disabledAll() {

				if (this.disabledPay) {
					return true
				} else {
					return false
				}
			}
		},
		mounted () {
			this.viewNoticeDOM = document.getElementById('viewNotice')
			this.exportZIPDOM = document.getElementById('exportZIPDOM')
		},
		//axios获取的res.data.data是绑了get方法和set方法的变异数据。而vue的变异数据里每个属性都会被绑定。
		created() {
			// this.mergeTable();
		},
		methods: {
			openPayNotice () {
				this.isSendEmail = true
			},
			disabledSendPayNotice(data) {
				let sta = data.statuss
				let isSendAccept = sta.findIndex(v => v.id == 19)
				if(this.getSendPayNotice(sta) && isSendAccept != -1) {
					return true
				} else {
					return false
				}
			},
			uploadCredential(data) {
				this.$refs['uploadCredentialDialog'].show(data)
			},
			selectAll(val) {
				for( let i in this.tableHeader) {
					this.tableHeader[i] = val
				}
			},
			async tableDataRefresh() {
				// if (this.$store.state.user.role_id == 4) {
				// 	this.paramsByOrder.process_id = this.$store.state.user.id;
				// }
				let data = await orderFn.getFinalsOrder(this.$axios, this.$store, this.paramsByOrder);
				for (let key in data) {
					this[key] = data[key]
				}
			},

			//修改案件标红
			tableRowClassName({
				row,
				rowIndex
				}) {
				let cssClass = ""
				if (this.$store.state.user.role_id == 2 && row.status == "案件修改中") {
					cssClass = "warning-row"
				}
				return cssClass
			},
			//接单时间
			getOrderTakingTime(val) {
				let statusArr = val.statuss
				let createDay = ""
				for (const i in statusArr) {
					if (statusArr[i].id == 2) {
						createDay = statusArr[i].pivot.created_at
					}
				}
				return createDay;
			},

			// 处理耗时
			getProcessingTime(value) {
				//获取接单的时间戳
				let createTime = new Date(value.created_at).getTime()
				let nowTime = ''
				if (value.status == '等待提交国知局') {
					nowTime = new Date().getTime()
				} else {
					nowTime = new Date(value.submit_at).getTime()
				}
				// let nowTime = new Date(value.created_at).getTime();
				// if (value.submit_at) {
				// 	createTime = new Date(value.submit_at).getTime();
				// } else {
				// 	createTime = new Date(value.updated_at).getTime();
				// }
				//获取处理时间戳
				let cha = nowTime - createTime
				// function IsNaN(value) {
				// 	return typeof value === 'number' && isNaN(value);
				// }
				// if (IsNaN(cha)) {
				// 	return ''
				// }
				if (cha < 0) {
					cha = 0
				}
				//转换天数
				let round2 = (cha / 1000 / 60 / 60 / 24).toFixed(2)
			 	let	processingTime = (Math.ceil(round2 * 10) / 10).toFixed(1)
				if (processingTime < 0) {
					return '0.0'
				}  else if (processingTime < 0.1) {
					return '0.1'
				} else {
					return processingTime;
				}
			},

			getSendPayNotice (value) {
				let createTime = ''
				let nowTime = new Date()
				// for (let i = 0; i <value.length; i++ ) {
				// 	if (value[i].id == 19) {
				// 		createTime = new Date(value[i].pivot.created_at).getTime()
				// 	}
				// }
				if(value[value.findIndex(v => v.id == 11)]) {
					createTime = value[value.findIndex(v => v.id == 11)].pivot.created_at
				} else {
					return false
				}
				let cha = nowTime - createTime;
				let day = Math.floor(cha / 1000 / 60 / 60 / 24);
				if (day >= 30) {
					return false
				} else {
					return true
				}
			},

			//选择一页几条
			async handleSizeChange(size) {
				this.paramsByOrder.perPage = size
				this.paramsByOrder.page = 1
				// if (this.$store.state.user.role_id == 4) {
				// 	this.paramsByOrder.process_id = this.$store.state.user.id;
				// }

				let data = await orderFn.getFinalsOrder(this.$axios, this.$store, this.paramsByOrder);
				for (let key in data) {
					this[key] = data[key];
				}
			},
			//选择第几页
			async handleCurrentChange(val) {
				this.currentPage = val;
				// let parms = this.paramsByOrder
				this.paramsByOrder.page = val

				// if (this.$store.state.user.role_id == 4) {
				// 	this.paramsByOrder.process_id = this.$store.state.user.id;
				// }

				let data = await orderFn.getFinalsOrder(this.$axios, this.$store, this.paramsByOrder);
				for (let key in data) {
					this[key] = data[key];
				}
				// this.mergeTable();
			},
			//查看
			lookOrder(row) {
				if(window.getSelection().toString() === ''){
						// 查看订单
						if (row) {
							if(row.acceptance_note_file) {
								row.acceptanceFiles = [];
								let reviewfile = row.acceptance_note_file.split("&");
								for (let j in reviewfile) {
									let itemobj = {
											id: j + 1,
											path: reviewfile[j],
											file: ''
									};
									let itemArr = itemobj.path.split("/")
									itemobj.path = itemArr[itemArr.length - 1]
									itemobj.file = itemArr.slice(0, 2).join("/");
									row.acceptanceFiles.push(itemobj);
								}
							}
							if(row.demand_note_file) {
								row.demandFiles = [];
									let reviewfile = row.demand_note_file.split("&");
									for (let j in reviewfile) {
										let itemobj = {
												id: j + 1,
												path: reviewfile[j],
												file: ''
										};
										let itemArr = itemobj.path.split("/")
										itemobj.path = itemArr[itemArr.length - 1]
										itemobj.file = itemArr.slice(0, 2).join("/");
										row.demandFiles.push(itemobj);
									}
							}
							if(row.opinion_file) {
								row.opinionFiles = [];
									let reviewfile = row.opinion_file.split("&");
									for (let j in reviewfile) {
										let itemobj = {
												id: j + 1,
												path: reviewfile[j],
												file: ''
										};
										let itemArr = itemobj.path.split("/")
										itemobj.path = itemArr[itemArr.length - 1]
										itemobj.file = itemArr.slice(0, 2).join("/");
										row.opinionFiles.push(itemobj);
									}
							}
							if(row.answer_file) {
								row.answerFiles = [];
									let reviewfile = row.answer_file.split("&");
									for (let j in reviewfile) {
										let itemobj = {
												id: j + 1,
												path: reviewfile[j],
												file: ''
										};
										let itemArr = itemobj.path.split("/")
										itemobj.path = itemArr[itemArr.length - 1]
										itemobj.file = itemArr.slice(0, 2).join("/");
										row.answerFiles.push(itemobj);
									}
							}
						}
						this.orderRow = row
						this.order_process = null
						// if (row.order) {
						// 	this.order_process = row.order.process
						// }
						this.order_process = row.process
						this.order_agent = row.agent || null
						if (
							this.$store.state.user.role_id == 2 &&
							(row.order.status == "上报文件上传中" || row.status == "发明人确认定稿中")
						) {
							this.$refs.finalizationFile.showDialog(row);
						} else {
							if (this.$store.state.user.role_id == 1 || this.$store.state.user.role_id == 7) {
								this.$refs.orderDialog.showDialog(row.id, "处理中", 'formProcess', row);
							} else {
								this.$refs.orderDialog.showDialog(row.id, "处理中", 'formProcess');
							}
							// this.$refs.orderDialog.showDialog(row.id, "处理中", 'formProcess');
						}
					}

			},
			//流程
			editOrder(row) {
				this.$refs.scheduleDialog.showDialog(row.order);
			},
			//获取表格数据
			async getData(pStatus) {
				this.paramsByOrder = {
					status: '修改,等待提交国知局,已提交国知局,等待补正,已补正,等待答复,已答复,发明人确认答复中,发明人确认补正中,初步审查合格,实质审查中,驳回,授权,下证,撤案'
				}
				// if (this.$store.state.user.role_id == 4) {
				// 	this.paramsByOrder.process_id = this.$store.state.user.id;
				// }
				if (pStatus) {
					if (pStatus != '等待提交国知局') {
						this.paramsByOrder.annual_fee = pStatus
						this.paramsByOrder.status = '下证'
					} else {
						this.paramsByOrder.status = pStatus
					}
				}
				let data = await orderFn.getFinalsOrder(this.$axios, this.$store, this.paramsByOrder);
				for (let key in data) {
					this[key] = data[key]
				}

				this.currentPage = 1
				// 重绘表格解决错位问题
				// this.$nextTick(()=>{
				// 	this.$refs.orderTb.doLayout()
				// })
				// this.mergeTable();
			},

			callback() {},

			//导出excel
			exportExcel(name) {
				const loading = this.$loading({
          lock: true,
          text: '数据导出中。。。',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });

				let tabHandle = [
					"订单编号",
					"拟申报名称",
					"定稿名称",
					"代理人",
					"专利类型",
					"申请号",
					"申报时间",
					"定稿时间",
					"发明人提交时间",
					"第一发明人",
					"身份证号",
					"专利权人",
					"发明人",
					"联络人",
					"邮箱",
					"电话",
					"订单总耗时",
					"流程状态",
					"备注",
				]
				this.paramsByOrder.allPage = 2
				getFinalsList(this.$axios, this.paramsByOrder)
					.then(res => {
						if (res.data.code == 200) {
							loading.close()
							this.$confirm('是否导出压缩包及表格文件', '提示', {
								distinguishCancelAndClose: true,
								confirmButtonText: '确定',
								cancelButtonText: '只导出表格文件',
								center:true,
							})
							.then(() => {
								let tableData = [];
								let item = {}
								for (let i in JSON.parse(JSON.stringify(res.data.data))) {
									item = res.data.data[i]
									tableData.push(item);
								}
								this.$refs.TerminalExportExcel.exportExcelToIP2(name, tabHandle, tableData)

									// this.exportCpcURL = res.data.zippath
									this.exportZIPDOM.href = `${this.apiAddress}/storage/upload/${res.data.zippath}`
									this.exportZIPDOM.click()
							})
							.catch(action => {
								if(action === 'cancel') {
									let tableData = [];
									let item = {}
									for (let i in JSON.parse(JSON.stringify(res.data.data))) {
										item = res.data.data[i]
										tableData.push(item);
									}
									this.$refs.TerminalExportExcel.exportExcelToIP2(name, tabHandle, tableData)
								}
							})

							// this.$confirm('数据处理完毕,请选择导出方式。', '提示', {
							// 	distinguishCancelAndClose: true,
							// 	confirmButtonText: '导出Excel文件',
							// 	cancelButtonText: '导出压缩包文件',
							// 	center:true,
							// })
							// .then(() => {
							// 	let tableData = [];
							// 	let item = {}
							// 	for (let i in JSON.parse(JSON.stringify(res.data.data))) {
							// 		item = res.data.data[i]
							// 		tableData.push(item);
							// 	}
							// 	this.$refs.TerminalExportExcel.exportExcelToIP2(name, tabHandle, tableData);
							// })
							// .catch(action => {
							// 	if(action === 'cancel') {
							// 		// this.exportCpcURL = res.data.zippath
							// 		this.exportZIPDOM.href = `${this.apiAddress}/storage/upload/${res.data.zippath}`
							// 		this.exportZIPDOM.click()
							// 	}
							// })
						}
					})
			},

			//获取所有代理人， 流程人员信息
			getAllAgent() {
				this.$axios.get('api/user/agent/all')
					.then(res => {
						if (res.data.code == 200) {
							this.agentOptions = res.data.data
						}
					})
					.catch(err => {
						this.$message({
							type: "err",
							message: err
						});
					});
				this.$axios.get('api/user/process')
					.then(res => {
						if (res.data.code == 200) {
							this.processOptions = res.data.data
						}
					})
					.catch(err => {
						this.$message({
							type: "err",
							message: err
						});
					});

			},

			async search() {
				this.currentPage = 1
				for (var i = 0; i < this.conditionForm.condition.length; i++) {
					let a = this.conditionForm.condition[i].parameter
					if (this.conditionForm.condition[i].parameter === 'subimt_time') {
						this.paramsByOrder.submit_start_time = this.submitTime[0]
						this.paramsByOrder.submit_end_time = this.submitTime[1]
					}
					if (this.conditionForm.condition[i].parameter === 'created_time') {
						this.paramsByOrder.start_time = this.createdTime[0]
						this.paramsByOrder.end_time = this.createdTime[1]
					}
					if (this.conditionForm.condition[i].parameter === 'updated_time') {
						this.paramsByOrder.updated_start_time = this.updatedTime[0]
						this.paramsByOrder.updated_end_time = this.updatedTime[1]
					}
					if (this.conditionForm.condition[i].parameter === 'order_created') {
						this.paramsByOrder.order_created_start = this.userSubmitTime[0]
						this.paramsByOrder.order_created_end = this.userSubmitTime[1]
					}
					this.paramsByOrder[a] = this.conditionForm.condition[i].value
				}
				// if (this.$store.state.user.role_id == 4) {
				// 	this.paramsByOrder.process_id = this.$store.state.user.id;
				// }


				// 处理分页数据
				delete this.paramsByOrder.page

				// 处理排序状态
				delete this.paramsByOrder.sort_str
				delete this.paramsByOrder.sort_order
				this.$refs['orderTb'].clearSort()

				let data = await orderFn.getFinalsOrder(this.$axios, this.$store, this.paramsByOrder);
				for (let key in data) {
					this[key] = data[key];
				}
				// this.mergeTable()
				this.showFilter = false
			},
			// 添加条件筛选
			addFilterCondition(item) {
				let filterItem = {
					value: '',
					label: item.label,
					parameter: item.parameter,
					key: Date.now()
				}

				if (this.conditionForm.condition.length > 0) {
					let conditionlabels = []
					for (let i = 0; i < this.conditionForm.condition.length; i++) {
						conditionlabels.push(this.conditionForm.condition[i].label)
					}
					let Check = conditionlabels.indexOf(item.label)
					Check == -1 ? this.conditionForm.condition.push(filterItem) : this.$message.error('请勿重复添加')
				} else {
					this.conditionForm.condition.push(filterItem)
				}

				this.showFilterCondition = false;
			},
			resetForm(formName) {
				this.$refs[formName].resetFields()
				this.$refs['orderTb'].clearSort()
				this.conditionForm.condition.forEach(v => {
					if (v.value) {
						v.value = null
					}
				});
				this.showFilterCondition = false
				this.submitTime = []
				this.createdTime = []
				this.updatedTime = []
				this.userSubmitTime = []
				this.paramsByOrder = {
					status: "修改,等待提交国知局,提交国知局,等待补正,已补正,等待答复,已答复,发明人确认答复中,发明人确认补正中,初步审查合格,实质审查中,驳回,授权,下证,撤案"
				}
				this.$nextTick(() => {
					this.$refs[formName].clearValidate()
				})
				// this.getData()
				// // this.mergeTable()
				// this.showFilter = false
			},
			submitsearch(formName) {
				let that = this
				this.$refs[formName].validate((valid, prop) => {
					// this.$refs[formName].clearValidate();
					let props = []
					for (let k in prop) {
						props.push(prop[k][0].field)
						if (prop[k][0].message = '申报时间不能为空') {
							if (that.updatedTime) {
								if (that.updatedTime.length > 0) {
									that.$refs[formName].clearValidate([prop[k][0].field])
									// that.search()
									let timeIndex = props.indexOf('申报时间不能为空')
									props.splice(timeIndex, 1)
								}
							} else {
								return false
							}
						}
						if (prop[k][0].message = '更新时间不能为空') {
							if (that.submitTime) {
								if (that.submitTime.length > 0) {
									that.$refs[formName].clearValidate([prop[k][0].field])
									// that.search()
									let timeIndex = props.indexOf('申报时间不能为空')
									props.splice(timeIndex, 1)
								}
							} else {
								return false
							}
						}
						if (prop[k][0].message = '定稿时间不能为空') {
							if (that.createdTime) {
								if (that.createdTime.length > 0) {
									that.$refs[formName].clearValidate([prop[k][0].field])
									// that.search()
									let timeIndex = props.indexOf('定稿时间不能为空')
									props.splice(timeIndex, 1)
								}
							} else {
								return false
							}
						}
						if (prop[k][0].message = '发明人提交时间不能为空') {
							if (that.userSubmitTime) {
								if (that.userSubmitTime.length > 0) {
									that.$refs[formName].clearValidate([prop[k][0].field])
									// that.search()
									let timeIndex = props.indexOf('发明人提交时间不能为空')
									props.splice(timeIndex, 1)
								}
							} else {
								return false
							}
						}
					}
					if (props.length) {
						that.$refs[formName].validateField(props, (valid2) => {
							if (valid2) {
								return false;
							} else {
								that.search()
							}
						})
					} else {
						that.search()
					}
				})
			},
			removeDomain(item) {
				this.showFilter = true
				delete this.paramsByOrder[item.parameter]
				let index = this.conditionForm.condition.indexOf(item)
				if (index !== -1) {
					this.conditionForm.condition.splice(index, 1)
				}
				if (item.label === '申报时间') {
					this.submitTime = []
					delete this.paramsByOrder.submit_start_time
					delete this.paramsByOrder.submit_end_time
				}
				if (item.label === '更新时间') {
					this.updatedTime = []
					delete this.paramsByOrder.updated_start_time
					delete this.paramsByOrder.updated_end_time
				}
				if (item.label === '定稿时间') {
					this.createdTime = []
					delete this.paramsByOrder.start_time
					delete this.paramsByOrder.end_time
				}
				if (item.label === '发明人提交时间') {
					this.userSubmitTime = []
					delete this.paramsByOrder.order_created_start
					delete this.paramsByOrder.order_created_end
				}
				this.search()
			},
			changInput () {
				this.$refs['conditionForm'].clearValidate();
			},
			sendPayNotice (data) {
				this.orderID = data.id
				this.orderRow = data

				// if (data.consumer_pay_status == 1) {
				// 	this.sendType = '2'
				// } else {
				// 	this.sendType = '1'
				// }
				let sta = data.statuss
				let isPay = data.consumer_pay_status == 1 || data.consumer_pay_status == 0
				if(this.getSendPayNotice(sta) || isPay) {
					this.sendType = '2'
				} else {
					this.sendType = '1'
				}

				this.showSendPayNotice = true
			},
			// 预览缴费通知书
			viewNotice () {
				let list = document.getElementsByClassName(
					"el-upload-list__item is-ready"
				)
				// FormData 对象
        let form = new FormData()

				if (list.length > 0) {
					form.append('file2', this.fileListV2[0].raw);
				}
				axios({
					method: "post",
					url: this.baseUrl + `/api/finals/${this.orderID}/view/notice`,
					data: form,
					headers: {
						"Content-Type": "multipart/form-data",
						Authorization: "Bearer " + this.$store.state.token
					}
				}).then(res => {
					if (res.data.status == "success") {
						this.viewNoticeDOM.href = `${this.apiAddress}/storage/upload/${res.data.data.path}`
						this.viewNoticeDOM.click()
					} else {
						this.$message({
							type: "error",
							message: res.data.message
						})
					}
				})
			},

			// 修改缴费通知书
			editNotice () {
				let list = document.getElementsByClassName(
					"el-upload-list__item is-ready"
				)

				if (list.length > 0) {

					this.$refs.editNoticeDialog.show(this.orderID, this.fileListV2[0].raw)
				} else {
					if (this.sendType == '1') {
						this.$refs.editNoticeDialog.show(this.orderID)
					} else {
						this.$alert('请先上传受理通知书后再修改缴费通知书!', '温馨提示',  {
						confirmButtonText: '确定',
							center: true,
							callback: action => {
							}
						})
					}
					// this.$refs.editNoticeDialog.show(this.orderID)
				}


			},

			submitPayNotice () {
				this.sendPayNoticeLoading = true
				let list = document.getElementsByClassName(
					"el-upload-list__item is-ready"
				);
				// if (list.length == 0) {
				// 	this.$message({
				// 		type: "warning",
				// 		message: "请选择需要上传的文件！"
				// 	});
				// 	return;
				// }
        let pData = {
          finals: this.orderID
        }
				// FormData 对象
        let form = new FormData();

				// form.append('file1', this.fileListV[0].raw);
				if (this.sendType != '1') {
					if (list.length > 0) {
						form.append('file2', this.fileListV2[0].raw);
					} else if (list.length == 0) {
						this.$message({
							type: "warning",
							message: "请选择需要上传的文件！"
						})
						this.sendPayNoticeLoading = false
						return
					}
				}

				if(this.isSendEmail) {
					form.append('is_email', '1')
				} else {
					form.append('is_email', '2')
				}

				form.append('finals', this.orderID)
				form.append('send_type', this.sendType)
				axios({
					method: "post",
					url: this.baseUrl + `/api/finals/${this.orderID}/send/notice`,
					data: form,
					headers: {
						"Content-Type": "multipart/form-data",
						Authorization: "Bearer " + this.$store.state.token
					}
					}).then(res => {
					if (res.data.code == 200) {
						this.$alert('缴费通知发送成功!', '温馨提示', {
							confirmButtonText: '确定',
							center: true,
							callback: action => {
							}
						})
						this.sendPayNoticeLoading = false
						this.search()
						this.fileListV = []
						this.showSendPayNotice = false
					} else {
						this.$message({
							type: "error",
							message: res.data.message
						});
						this.sendPayNoticeLoading = false
						this.fileList2 = []
						this.fileListV2 = []
					}
				})
			},

      handleRemove1(file, fileList) {
				this.fileListV2 = fileList;
      },
			closeSendPayNotice () {
				this.fileList = [];
				this.fileListV = []
				this.fileList2 = []
				this.fileListV2 = []
			},

      handleChange1(file, fileList) {
				let tempList = [];//可以上传的文件
				let that = this;
				let canUpload = true;//是否可以上传
				let fileName,
						fileNameArr,
						arrLen,
						pos,
						fileDate,
						lastName,
						finalName,
						application,
						orderNum =''
				let dateReg = /^((?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)|([0-9]{2}(0[48]|[2468][048]|[13579][26])|(0[48]|[2468][048]|[13579][26])00)-02-29)$/
				for(let i = 0;i<fileList.length;i ++){
					// //验证文件类型
					fileName = fileList[i].name
					pos = fileName.lastIndexOf(".")
					// 获取文件名中的日期
					fileDate = `${fileName.split('_')[0]}`
					console.log(fileDate)
					// 去除时间开始抽取订单编号
					orderNum = fileName.substr(11, that.orderRow.order_number.length)
					console.log(orderNum)
					// 申报名称
					finalName = fileName.substring(11 + that.orderRow.order_number.length + 1).split('_')[0]
					console.log(finalName)
					// 后缀名
					lastName = fileName.substring(pos, fileName.length)
					console.log(lastName)
					// 申请号
					arrLen = fileName.split('_')
					console.log(arrLen)
					application = arrLen[arrLen.length-1].split('.')[0]

					if(!dateReg.test(fileDate)) {
						that.$message.error('日期格式错误，正确的格式为：yyyy-mm-dd')
						canUpload = false
					} else if (orderNum != that.orderRow.order_number) {
						that.$message.error("订单编号不正确")
						canUpload = false
					} else if (finalName != that.orderRow.name) {
						that.$message.error("申报名称不正确")
						canUpload = false
					} else if (application.length != 13) {
						that.$message.error("申请号格式不正确")
						canUpload = false
					} else if ( lastName.toLowerCase() !== ".pdf" && lastName.toLowerCase() !== ".rar"  && lastName.toLowerCase() !== ".zip") {
						that.$message.error("文件必须为 pdf 格式或 rar/zip格式");
						canUpload = false;
					}
					if(canUpload){
						tempList.push(fileList[i]);
					}
				}
				this.fileListV2.splice(0,this.fileListV2.length,...tempList);
				fileList.splice(0, fileList.length,...tempList);
				return ;
			},
			uploadSectionFile(params) {
			},
			// 表格排序
			async	tableSortChange(column) {
				if (column.order === 'descending') {
					this.paramsByOrder.sort_str = column.prop
					this.paramsByOrder.sort_order = 'desc'
				} else if (column.order === 'ascending') {
					this.paramsByOrder.sort_str = column.prop
					this.paramsByOrder.sort_order = 'asc'
				} else {
					delete this.paramsByOrder.sort_str
					delete this.paramsByOrder.sort_order
				}

				// if (column.prop == 'opinions_count') {
				// 	this.tableData.sort((a, b) => {
				// 		return a.order.opinions.length > b.order.opinions.length ? 1 : -1
				// 	})
				// }
				this.loading = true
				// if (this.$store.state.user.role_id == 4) {
				// 	this.paramsByOrder.process_id = this.$store.state.user.id;
				// }

				let data = await orderFn.getFinalsOrder(this.$axios, this.$store, this.paramsByOrder);
				for (let key in data) {
					this[key] = data[key];
				}
			},
			stopLook(path) {

			},
			// update (row) {
			// 	this.$refs.updateDialog.show(row)
			// }
		},
		watch: {
			tableHeader: {
				handler: function(val) {
					let arr = JSON.parse(JSON.stringify(val))
					delete arr.checked
					let select_all = true,
						checked = false
					for (let i in arr) {
						if (arr[i] == false) {
							select_all = false
						}
						if (arr[i] == true) {
							checked = true
						}
					}
					this.checked99 = checked
					if (select_all) {
						this.tableHeader.checked = true
					} else {
						this.tableHeader.checked = false
					}
				},
				deep: true
			},
			orderRow: {
				handler: function (val) {
					if (val.order_number.split('-')[0] == 'ZN' || val.order_number.split('-')[0] == 'ZY') {
						this.disabledEditPayNotice = true
					} else {
						this.disabledEditPayNotice = false
					}
				}
			}
		},
		beforeUpdate() {
			this.$nextTick(() => {
				this.$refs.orderTb.doLayout();
			});
		}
	};
</script>

<style lang="less" scoped>
	.inProcessing2 {
    height: 100%; //撑满表格
    .el-table {
      width: 99.9% !important;
    }
  }
	.file_sh {
		font-size: 25px;
		margin-right: 10px;
	}

	/deep/.el-table .warning-row {
		background: oldlace;
		overflow-y: auto;
	}

	.el-main .ivu-poptip .ivu-poptip-popper .ivu-poptip-content .ivu-poptip-inner {
		min-width: 480px;
		// height: 300px;
		overflow-y: scroll;
	}

	.poptip-condition {
		display: block;
		margin-top: 10px;

		.poptip-condition-item {
			line-height: 25px;
			cursor: pointer;
		}

		.poptip-condition-add {
			font-size: 14px;
		}
	}

	.demo-dynamic {
		padding-left: 10px;

		.el-form-item {
			margin-bottom: 12px;
		}

		.el-input {
			width: 240px;
		}

		.el-date-editor {
			width: 240px;
		}

		.el-button {
			padding: 9px 15px;
			vertical-align: baseline;
		}

		.el-form-item__error {
			padding-top: 0;
		}

	}

	.el-main .poptip-condition .ivu-poptip-popper .ivu-poptip-content .ivu-poptip-inner {
		min-width: 180px;
	}

	.btn-send {
		margin: 20px 10px 0 0 !important;
	}

	.sendPayNoticeDialog {
		.el-dialog {
			min-width: 450px !important;
		}
		.el-select {
			margin-bottom: 20px;
		}
	}

	.btns {
		margin-top: 10px;
	}
	.tableLastCol {
		padding-right: 20px;
	}
	.tableLastCol3 {
		padding-right: 20px;
	}
	.down-execel {
		display: block;
		height: 40px;
		line-height: 40px;
		color: #333333;
		font-size: 14px;
		margin-right: 20px;
		float: right;
	}
	.exportExcel {
		i {
			color: #333333;
		}
	}

</style>
